package com.hero.take.util;

import io.netty.util.internal.StringUtil;

import java.util.Date;

public class BizCommon {

    /**
     * 工单号生成
     *
     * @return
     */
    public static String workOrderNoMake(String preNo) {
        String workOrderNo = "GD" + DateHelpper.dateStr(new Date(), DateTimeFormat.yyyyMMddNoWhip);
        if (StringUtil.isNullOrEmpty(preNo)) {
            workOrderNo += "0001";
        } else {
            int flowNo = Integer.parseInt(preNo.substring(preNo.length() - 4)) + 1;
            String flowNoStr = "0000" + flowNo;
            flowNoStr = flowNoStr.substring(flowNoStr.length() - 4);
            workOrderNo += flowNoStr;
        }
        return workOrderNo;
    }

    /**
     * 手机号脱敏
     * @param mobile
     * @return
     */
    public static String mobileShuck(String mobile)
    {
        if (mobile == null || mobile.length() < 11) return mobile;
        String first = mobile.substring(0, mobile.length() - 5);
        String second = mobile.substring(9);
        return first + "****" + second;
    }
}
